package cn.uexpo.lhz.biz.impl;

import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



import cn.uexpo.lhz.biz.ManageEquipmentBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.ManageEquipmentMapper;
import cn.uexpo.lhz.domain.ManageEquipment;
import cn.uexpo.lhz.domain.ManageEquipmentExample;

@Service
public class ManageEquipmentBizImpl implements ManageEquipmentBiz {

	@Autowired
	private ManageEquipmentMapper manageEquipmentMapper;

	@Override
	public int insert(ManageEquipment record) throws BOException {
		return manageEquipmentMapper.insert(record);
	}

	@Override
	public int insertSelective(ManageEquipment record) throws BOException {
		return manageEquipmentMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		return manageEquipmentMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(ManageEquipment record) throws BOException {
		return manageEquipmentMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		int no=0;
		if (null!=ids) {
			for (Integer id : ids) {
				no=manageEquipmentMapper.deleteByPrimaryKey(id);
				if (no==0) {
					throw new RuntimeException("删除失败。") ;
				}
			}
		}

		return no;
	}

	@Override
	public int delete(List<ManageEquipment> records) throws BOException {
		int no=0;
		if (null!=records&&records.size()>0){
			for (ManageEquipment equipmentEntity : records) {
				no=manageEquipmentMapper.deleteByPrimaryKey(equipmentEntity.getId());
				if (no==0) {
					throw new RuntimeException("删除失败。") ;
				}
			}
		}

		return no;
	}

	@Override
	public int deleteByExample(ManageEquipmentExample example) throws BOException {
		return manageEquipmentMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(ManageEquipment record) throws BOException {
		return manageEquipmentMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(ManageEquipment record) throws BOException {
		return manageEquipmentMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(ManageEquipment record, ManageEquipmentExample example) throws BOException {
		return manageEquipmentMapper.updateByExampleSelective(record, example);
	}

	@Override
	public int updateByExample(ManageEquipment record, ManageEquipmentExample example) throws BOException {
		return manageEquipmentMapper.updateByExample(record, example);
	}

	@Override
	public ManageEquipment selectByPrimaryKey(Integer id) throws BOException {
		return manageEquipmentMapper.selectByPrimaryKey(id);
	}

	@Override
	public ManageEquipment selectByUniqueCode(String uniqueCode) throws BOException {

		return null;
	}

	@Override
	public List<ManageEquipment> selectByExample(ManageEquipmentExample example) throws BOException {
		return manageEquipmentMapper.selectByExample(example);
	}

	@Override
	public long countByExample(ManageEquipmentExample example) throws BOException {
		return manageEquipmentMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, ManageEquipmentExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<ManageEquipment> records = (List<ManageEquipment>) manageEquipmentMapper.selectByExample(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<ManageEquipment>(records));
	}

	public PageResult findPage1(PageRequest pageRequest, ManageEquipment manageEquipment) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<ManageEquipment> records = manageEquipmentMapper.listShow(manageEquipment);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<ManageEquipment>(records));
	}
	@Override
	public List<ManageEquipment> listShow(ManageEquipment manageEquipment) {
		List<ManageEquipment> list = manageEquipmentMapper.listShow(manageEquipment);
		return list;
	}

	@Override
	public List<ManageEquipment> selectByExampleWithBLOBs(ManageEquipmentExample example) throws BOException {
		return manageEquipmentMapper.selectByExampleWithBLOBs(example);
	}

	@Override
	public int updateByExampleWithBLOBs(ManageEquipment record, ManageEquipmentExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(ManageEquipment record) throws BOException {
		return manageEquipmentMapper.updateByPrimaryKeyWithBLOBs(record);
	}

	@Override
	public List<ManageEquipment> selectManageEquipmentDependencyAllByID(ManageEquipment record) {
		return manageEquipmentMapper.selectManageEquipmentDependencyAllByID(record);
	}

	@Override
	public int updateByPrimaryKey2(ManageEquipment record) {
		return manageEquipmentMapper.updateByPrimaryKey2(record);
	}

	@Override
	public List<Map> selectManageEquipmentAll(ManageEquipment record) {
		// TODO Auto-generated method stub
		return manageEquipmentMapper.selectManageEquipmentAll(record);
	}

	@Override
	public List<ManageEquipment> selectAll() {
		return manageEquipmentMapper.selectAll();
	}

	@Override
	public int updateByextStr2s(List<Integer> list) {
		return manageEquipmentMapper.updateByextStr2s(list);
	}


}
